package Control;

import java.io.IOException;
import java.util.Scanner;
import Game.ActionType;
import Game.GameBox;
import Game.Group;
import Game.*;
import show.showBox_Group;
import java.lang.Math;


public class Controller {
    public Group group;
    protected GameBox gameBox;

    Controller(GameBox gameBox){
        this.gameBox = gameBox;
    }
//    static public void test(){
//        try{
//            char c =  (char)System.in.read();
//            System.out.println(c);
//        }catch (IOException e){
//            e.printStackTrace();
//        }
//    }
//
//    public char cmd ;
//    public void recieve(){
//            Scanner scanner = new Scanner(System.in);
//            String _cmd =  scanner.nextLine();
//            this.cmd = _cmd.charAt(0);
////            this.cmd =  (char)System.in.read();
//    }
//
//    public ActionType out() throws Exception {
//        return getActionType(cmd);
//    }

    public static void main(String[] args) throws Exception {

//        Controller controller = new Controller(new GameBox(10,10));
//        controller.prepare();
//        GameBox gameBox = new GameBox(5,5);
////        Group group = GroupGenerator.generateTGroup(5,3);
//        Group group = controller.group;
//        Receiver receiver = new Receiver();
//        while(true){
//            receiver.restart();
//            receiver.receive();
//            ActionType action = Translator.translate(receiver.result());
//            if (CollisionDetector.crashed(gameBox,group,action)){
//                ;
//            }else{
//                group.move(action);
//            }
//
//            showBox_Group.show(gameBox,group);
//        }

        for (int i = 0 ; i < 10 ; i ++){
            Controller controller = new Controller(new GameBox(10,10));
            controller.prepare();
            System.out.println();
        }


    }

    public void prepare(){
        //随机准备一个方块
        int idx = (int)(Math.random() * 5);
        System.out.println(idx);
        switch (idx){
            case 0 : this.group = GroupGenerator.generateOGroup(0,0);break;
            case 1 : this.group = GroupGenerator.generateTGroup(1,0);break;
            case 2 : this.group = GroupGenerator.generateIGroup(1,0);break;
            case 3 : this.group = GroupGenerator.generateZGroup(1,0);break;
            case 4 : this.group = GroupGenerator.generateSGroup(1,-1);break;
        }
//        this.group.move(ActionType.DOWN);
//        showBox_Group.show(this.gameBox,this.group);
    }
}
